package io.renren.modules.meta.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.meta.entity.EventSubjectEntity;
import io.renren.modules.meta.service.EventSubjectService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 事件主体关联表
 *
 * @author linyuan
 * @email linyuan@gmail.com
 * @date 2023-08-30 10:44:10
 */
@RestController
@RequestMapping("meta/eventsubject")
public class EventSubjectController {
    @Autowired
    private EventSubjectService eventSubjectService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("meta:eventsubject:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = eventSubjectService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{esId}")
    @RequiresPermissions("meta:eventsubject:info")
    public R info(@PathVariable("esId") Integer esId){
		EventSubjectEntity eventSubject = eventSubjectService.getById(esId);

        return R.ok().put("eventSubject", eventSubject);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("meta:eventsubject:save")
    public R save(@RequestBody EventSubjectEntity eventSubject){
		eventSubjectService.save(eventSubject);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("meta:eventsubject:update")
    public R update(@RequestBody EventSubjectEntity eventSubject){
		eventSubjectService.updateById(eventSubject);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("meta:eventsubject:delete")
    public R delete(@RequestBody Integer[] esIds){
		eventSubjectService.removeByIds(Arrays.asList(esIds));

        return R.ok();
    }

}
